#include <stdio.h>
#include <string.h>
#include <unistd.h>

int main()
{

  int a = 12345;
  char buffer[1024];
  snprintf(buffer, sizeof(buffer), "%d", a);
  //const char *m = "hello";
  write(1, buffer, strlen(buffer));
  
  printf("hello wrold\n");
  fputs("aaaa", stdout);
  fwrite("bbbb", 1, 4, stdout);
  fprintf(stdout, "cccc");
  
  FILE *fp = fopen("log.txt", "a"); // append
  if(fp == NULL)
  {
      perror("fopen");
      return 1;
  }
  
  char buffer[1024];
  const char *message = "hello bit";
  int i = 0;
  while(i < 10)
  {
      snprintf(buffer, sizeof(buffer), "%s:%d\n", message, i);
      fputs(buffer, fp);
      i++;
  }
  
  fclose(fp);
    return 0;
}
